package cn.sunxyz.data.infer.parser.conditions;

import cn.sunxyz.data.infer.parser.NameParser;
import cn.sunxyz.data.infer.SQLDialect;

/**
 * Created by yangrd on 2017/5/31.
 */
public enum ConditionsParserManager {

    //单例
    My_SQL(new MySQLParser()),
    ORACLE(new OracleParser());

    private NameParser parser;

    ConditionsParserManager(NameParser parser) {
        this.parser = parser;
    }

    public static NameParser getParserByDialect(SQLDialect sqlDialect) {
        switch (sqlDialect) {
            case MY_SQL:
                return My_SQL.getParser();
            case ORACLE:
                return ORACLE.getParser();
        }
        throw new RuntimeException();
    }

    public NameParser getParser() {
        return parser;
    }
}
